package com.mnyc.research.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.mnyc.common.annotation.BaseEntityParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mnyc.common.annotation.Log;
import com.mnyc.common.core.controller.BaseController;
import com.mnyc.common.core.domain.AjaxResult;
import com.mnyc.common.enums.BusinessType;
import com.mnyc.research.domain.JySchoolResearchActivity;
import com.mnyc.research.service.IJySchoolResearchActivityService;
import com.mnyc.common.utils.poi.ExcelUtil;
import com.mnyc.common.core.page.TableDataInfo;

/**
 * 校本教研活动Controller
 *
 * @author wdy
 * @date 2025-08-08
 */
@RestController
@RequestMapping("/research/ySchoolResearchActivity")
public class JySchoolResearchActivityController extends BaseController {
    @Autowired
    private IJySchoolResearchActivityService jySchoolResearchActivityService;

    /**
     * 查询 校本教研活动列表
     */
    @PreAuthorize("@ss.hasPermi('research:ySchoolResearchActivity:list')")
    @GetMapping("/list")
    public TableDataInfo list(@BaseEntityParam JySchoolResearchActivity jySchoolResearchActivity) {
        startPage();
        List<JySchoolResearchActivity> list = jySchoolResearchActivityService.selectJySchoolResearchActivityList(jySchoolResearchActivity);
        return getDataTable(list);
    }

    /**
     * 导出 校本教研活动列表
     */
    @PreAuthorize("@ss.hasPermi('research:ySchoolResearchActivity:export')")
    @Log(title = " 校本教研活动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JySchoolResearchActivity jySchoolResearchActivity) {
        List<JySchoolResearchActivity> list = jySchoolResearchActivityService.selectJySchoolResearchActivityList(jySchoolResearchActivity);
        ExcelUtil<JySchoolResearchActivity> util = new ExcelUtil<JySchoolResearchActivity>(JySchoolResearchActivity.class);
        util.exportExcel(response, list, " 校本教研活动数据");
    }

    /**
     * 获取 校本教研活动详细信息
     */
    @PreAuthorize("@ss.hasPermi('research:ySchoolResearchActivity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(jySchoolResearchActivityService.selectJySchoolResearchActivityById(id));
    }

    /**
     * 新增 校本教研活动
     */
    @PreAuthorize("@ss.hasPermi('research:ySchoolResearchActivity:add')")
    @Log(title = " 校本教研活动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JySchoolResearchActivity jySchoolResearchActivity) {
        return toAjax(jySchoolResearchActivityService.insertJySchoolResearchActivity(jySchoolResearchActivity));
    }

    /**
     * 修改 校本教研活动
     */
    @PreAuthorize("@ss.hasPermi('research:ySchoolResearchActivity:edit')")
    @Log(title = " 校本教研活动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JySchoolResearchActivity jySchoolResearchActivity) {
        return toAjax(jySchoolResearchActivityService.updateJySchoolResearchActivity(jySchoolResearchActivity));
    }

    /**
     * 删除 校本教研活动
     */
    @PreAuthorize("@ss.hasPermi('research:ySchoolResearchActivity:remove')")
    @Log(title = " 校本教研活动", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return toAjax(jySchoolResearchActivityService.deleteJySchoolResearchActivityById(id));
    }

    /**
     * 审核 校本教研活动
     */
    @PreAuthorize("@ss.hasPermi('research:ySchoolResearchActivity:audit')")
    @Log(title = " 校本教研活动", businessType = BusinessType.UPDATE)
    @PutMapping("audit")
    public AjaxResult audit(@RequestBody JySchoolResearchActivity jySchoolResearchActivity) {
        return toAjax(jySchoolResearchActivityService.audit(jySchoolResearchActivity));
    }

}
